package com.xiaoyang.ssyx.search.repository;

import com.xiaoyang.ssyx.model.search.SkuEs;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @AUTHOR XiaoYang
 * @DATE 2023/6/17-11:56
 * @DESCRIPTION TODO
 */

//                                                          操作的实体类 主键类型
@Component
public interface SkuRepository extends ElasticsearchRepository<SkuEs, Long> {

    //获取爆款商品
    //SpringData 会根据命名规范执行SQL
    Page<SkuEs> findByOrderByHotScoreDesc(Pageable pageable);

    //根据仓库id + 分类id查询
    Page<SkuEs> findByCategoryIdAndWareId(Long categoryId, Long wareId, Pageable pageable);

    //根据仓库id + keyword进行查询
    Page<SkuEs> findByKeywordAndWareId(String keyword, Long wareId, Pageable pageable);
}
